--[[/**
-- * 
 * 造成伤害 (效果同10)
 * 并移除等量生命上限
-- *
-- */]]

---@class BuffEffect441101 : BaseBuffEffect
BuffEffect441101 = ClientFight.CreateClass("BuffEffect441101", ClientFight.BaseBuffEffect)
local t = BuffEffect441101

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
    if (isDamageActionTrigger(buff)) then
        local isBuff = parameters[4];
        if (isBuff) then
            return IBuffEffect.FAIL;
        end
    end
    local calculatorType = buff.buffBean.f_BuffEffectValue[1];
    local damageType = buff.buffBean.f_BuffEffectValue[2];
    local calculateAttrType = buff.buffBean.f_BuffEffectValue[3];
    local bonus = buff.buffBean.f_BuffEffectValue[4] * 1;
    local modifiedRatio = buff.buffBean.f_BuffEffectValue[5] * 1;
    local calculator = calculatorType == 0 and buff.source or buff.target;

    local result = AttackUtils.calculateEffectDamage(buff.source, buff.target, damageType, calculator, calculateAttrType, modifiedRatio, bonus);
    DamageManager.realDamage(fight, buff.source, buff.target, buff.modelId, result, damageType);
    SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
            .. buff.modelId .. " 触发伤害，伤害值：" .. result.damage);
    --这是一个负数
    local oldValue = buff.attributes.attributes[FighterAttributeEnum.HP.id] or 0;
    local addHp = oldValue - result.damage;
    buff.attributes.attributes[FighterAttributeEnum.HP.id] = addHp;
    SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff:"
            .. buff.modelId .. " buff 导致生命上限发生变化: " .. addHp);

    ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
    return IBuffEffect.SUCCESS_ATTRI_HAS_CHANGE;
end

t.New()